package Jun13.doc;

import Jun13.utils.ESUtils;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

/**
 * @author Administrator
 */
public class DeleteDoc {

    public static void main(String[] args) throws IOException {
        //获取ES对象
        RestHighLevelClient rest = ESUtils.getRest();
        //创建删除对象，指定在哪个索引下删除哪个文档
        DeleteRequest index = new DeleteRequest().index("user").id("1001");
        //发送删除请求
        DeleteResponse result = rest.delete(index, RequestOptions.DEFAULT);
        //打印结果
        System.out.println(result.getResult());
        //关闭
        rest.close();
    }
}
